<?php
	header("Content-type: application/html; charset=UTF-8");
	define('_DOCUMENT_ROOT_', dirname(realpath(__FILE__)).'/');
	
	require_once(_DOCUMENT_ROOT_.'inc/config_front.php');
	require_once(_DOCUMENT_ROOT_.'lib/search_functions.php');
	require_once(_DOCUMENT_ROOT_.'inc/db_functions.php');
	
	if(isset($_REQUEST["region"]))
	{
		/******* countries of a region*******/
		$country_afr = search($_ARRAY_AREA_COUNTRY_,'AFR');
		$country_asi = search($_ARRAY_AREA_COUNTRY_,'ASI');
		$country_eur = search($_ARRAY_AREA_COUNTRY_,'EUR');
		$country_hgs = search($_ARRAY_AREA_COUNTRY_,'HGS');
		$country_oce = search($_ARRAY_AREA_COUNTRY_,'OCE');
		$country_sam = search($_ARRAY_AREA_COUNTRY_,'SAM');
		$country_usa = search($_ARRAY_AREA_COUNTRY_,'USA');
		
		$sVal = mysql_real_escape_string($_REQUEST["region"]);
		
		switch($sVal)
		{
			case "AFR":
				$re = $country_afr;
				break;
			case "ASI":
				$re = $country_asi;
				break;
			case "EUR":
				$re = $country_eur;
				break;
			case "HGS":
				$re = $country_hgs;
				break;
			case "OCE":
				$re = $country_oce;
				break;
			case "SAM":
				$re = $country_sam;
				break;
			case "USA":
				$re = $country_usa;
			default:
				break;
		}
		foreach($re as $key => $value)
		{
			foreach($value as $k => $v)
			{		
				echo"<option value='".$k."'>".$v."</option>";
			}
		}
	}
	if(isset($_REQUEST["country"]))
	{
		$sVal = mysql_real_escape_string($_REQUEST["country"]);
		/******* initialize db functions *******/
		$db = new db_functions();
		
		$city = $db->get_cities($sVal);

		for ($i=0;$i<count($city);$i++)
		{
			echo "<option value='".$city[$i]['city']."'>".$city[$i]['name']."</option>";
		}
	}
	else
	{
		return false;
	}

?>

	